# 设置最低版本号
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
# 设置项目名称
project(rk3588-demo VERSION 0.0.1 LANGUAGES CXX)

# 输出系统信息
message(STATUS "System: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")

# 设置编译器
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置库架构
set(LIB_ARCH "aarch64")
set(DEVICE_NAME "RK3588")

link_directories(
    mpp_api
    mk_api
)

# 寻找OpenCV库，使用自定义的OpenCV_DIR
set(3RDPARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set(RGA_DIR ${3RDPARTY_PATH}/rga/${DEVICE_NAME})
set(RGA_LIB ${RGA_DIR}/lib/Linux/${LIB_ARCH}/librga.so)
# set(OpenCV_DIR ${3RDPARTY_PATH}/opencv/opencv-linux-${LIB_ARCH}/share/OpenCV)
find_package(OpenCV REQUIRED)
# 输出OpenCV信息
message(STATUS "include path: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "${OpenCV_VERSION}")

# 用来搜索头文件的目录
include_directories(
    ${OpenCV_INCLUDE_DIRS}
    ${RKNN_API_INCLUDE_PATH}
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${RGA_DIR}/include
    ${CMAKE_CURRENT_LIST_DIR}/mpp_api/include
    ${CMAKE_CURRENT_LIST_DIR}/mk_api/include
    
)

# 测试usb_to_rtsp
add_executable(usb_to_rtsp 
        src/usb_to_rtsp.cpp
        src/rkmedia/utils/mpp_decoder.cpp
        src/rkmedia/utils/mpp_encoder.cpp
)

# 链接库
target_link_libraries(usb_to_rtsp
        rockchip_mpp 
        utils 
        mk_api 
        ${OpenCV_LIBS}
        ${RGA_LIB}
)

# 测试yolov8_video_track
add_executable(rtsp_to_rtsp 
        src/rtsp_to_rtsp.cpp
        src/rkmedia/utils/mpp_decoder.cpp
        src/rkmedia/utils/mpp_encoder.cpp
)

# 链接库
target_link_libraries(rtsp_to_rtsp
        rockchip_mpp 
        utils 
        mk_api 
        ${OpenCV_LIBS}
        ${RGA_LIB}
)

